﻿<UserControl x:Class="Agnes.TaskManager.TaskInfoEditView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:ext="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
             xmlns:lib="clr-namespace:Agnes.Libaray;assembly=Agnes.Libaray"
             xmlns:local="clr-namespace:Agnes.TaskManager"
             xmlns:csla="clr-namespace:Csla.Xaml;assembly=Csla.Xaml"
             mc:Ignorable="d" 
             Background="White"
             FontSize="13"
             d:DesignHeight="631" d:DesignWidth="807">
    
    <ScrollViewer>
        <Grid Margin="15"  >
            <Grid.Resources>
                <lib:BoolToCollapsedConverter x:Key="CollapsedConverter" />
                <local:CirculateTypeToCollapsedConverter x:Key="CirculateConverter" />
                <Style x:Key="LineStyle" TargetType="{x:Type Path}">
                    <Setter Property="Margin" Value="0,5,0,0" />
                    <Setter Property="StrokeThickness" Value="2" />
                    <Setter Property="Fill" Value="Black" />
                    <Setter Property="Stroke" Value="LightGray" />
                    <Setter Property="Data">
                        <Setter.Value>
                            <LineGeometry StartPoint="0,0" EndPoint="500,0" />
                        </Setter.Value>
                    </Setter>
                </Style>
            </Grid.Resources>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <TextBlock Grid.Row="0" Text="任务基本信息" FontSize="18" FontWeight="Bold"/>
            <Path Grid.Row="1" Style="{StaticResource LineStyle}" />
            <Grid Grid.Row="2" Margin="20,10,0,5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" Grid.Column="0" Margin="5" Text="名称:" VerticalAlignment="Center"/>
                <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="1">
                    <TextBox x:Name="lalTaskName" Text="{Binding Model.TaskName,UpdateSourceTrigger=PropertyChanged}" Margin="5" Width="150"/>
                    <csla:PropertyStatus Property="{Binding Model.TaskName}" Margin="5"/>
                </StackPanel>
                <TextBlock Grid.Row="0" Grid.Column="2" Margin="5" Text="优先级:" VerticalAlignment="Center"/>
                <ComboBox Grid.Row="0" Grid.Column="3" Margin="5" MinWidth="100" Background="Transparent" MaxWidth="100" HorizontalAlignment="Left"
                          ItemsSource="{Binding Path=PriorityLevelNVL}" 
                          DisplayMemberPath="Value" SelectedValuePath="Key"
                          SelectedValue="{Binding Model.PriorityLevel}"/>
                <TextBlock Grid.Row="3" Grid.Column="0" Margin="5" Text="标记类型:" VerticalAlignment="Center"/>
                <ComboBox Grid.Row="3" Grid.Column="1" Margin="5,0,0,5" MinWidth="150" HorizontalAlignment="Left" Background="Transparent"
                          ItemsSource="{Binding Path=TaskFlags}" Height="25" VerticalAlignment="Bottom"
                          SelectedValuePath="TaskFlag" SelectedValue="{Binding Model.TaskFlag}">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Image Source="{Binding Path=IcoUri}"/>
                                <TextBlock Text="{Binding Path=TaskFlagStr}" Margin="5,0,0,0"/>
                            </StackPanel>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
                <TextBlock Grid.Row="3" Grid.Column="2" Margin="5" Text="逾期日期:" VerticalAlignment="Center"/>
                <ext:DateTimePicker Grid.Row="3" Grid.Column="3" Margin="5" Value="{Binding Model.DueDT}" />
            </Grid>
            <TextBlock Grid.Row="3" Text="高级设置" FontSize="18" FontWeight="Bold" />
            <Path Grid.Row="4" Style="{StaticResource LineStyle}" />
            <Expander Grid.Row="5" Header="循环任务/提醒设置" Margin="10" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Row="0" Text="循环任务" FontSize="15" FontWeight="Bold" Margin="0,5,0,5"/>
                    <Path Grid.Row="1" Style="{StaticResource LineStyle}" />
                    <StackPanel Grid.Row="2" Margin="30,0,0,0">
                        <CheckBox x:Name="CirculateEnable" Content="启动循环任务" Margin="0,10,0,0"/>
                        <StackPanel Visibility="{Binding ElementName=CirculateEnable,Path=IsChecked,Converter={StaticResource CollapsedConverter}}">
                            <StackPanel  Orientation="Horizontal" >
                                <TextBlock Margin="0,10,0,0" Text="循环周期" VerticalAlignment="Center" />
                                <ComboBox x:Name="CirculateType" Margin=" 10,10,0,0" MinWidth="100" Background="Transparent" 
                                      ItemsSource="{Binding Path=CirculateTypeNVL}" SelectedValuePath="Key" DisplayMemberPath="Value"
                                      SelectedValue="{Binding Model.CirculateInfo.CirculateType}"/>
                            </StackPanel>
                            <StackPanel Visibility="{Binding ElementName=CirculateEnable,Path=IsChecked}">
                                <StackPanel Orientation="Horizontal" Margin="10,10,0,0"
                                        Visibility="{Binding ElementName=CirculateType,Path=SelectedValue,Converter={StaticResource CirculateConverter},ConverterParameter=Daily}">
                                    <TextBlock Text="每天定时启动: " VerticalAlignment="Center"/>
                                    <ext:TimePicker Margin="15,0,0,0" MinWidth="100" Value="{Binding Model.CirculateInfo.StartTime}"/>
                                </StackPanel>
                                <Grid Margin="10,10,0,0"
                                  Visibility="{Binding ElementName=CirculateType,Path=SelectedValue,Converter={StaticResource CirculateConverter},ConverterParameter=Weekly}" >
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
                                    <TextBlock Grid.Row="0" Text="在每周 " />
                                    <StackPanel Grid.Row="1"  Orientation="Horizontal">
                                        <local:WeekdaysCtrl Weekdays="{Binding Model.CirculateInfo.Weekdays,Mode=TwoWay}"/>
                                        <csla:PropertyStatus Property="{Binding Model.CirculateInfo.Weekdays}" Margin="5,0,0,0" />
                                    </StackPanel>
                                    <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0,5,0,0" >
                                        <TextBlock Text="的: " VerticalAlignment="Center"/>
                                        <ext:TimePicker Margin="10,0,0,0" MinWidth="100" Value="{Binding Model.CirculateInfo.StartTime}"/>
                                        <TextBlock Text="这个时候执行" VerticalAlignment="Center" Margin="10,0,0,0"/>
                                    </StackPanel>
                                </Grid>
                                <StackPanel Grid.Row="3" Margin="10,10,0,0" Orientation="Horizontal"
                                        Visibility="{Binding ElementName=CirculateType,Path=SelectedValue,Converter={StaticResource CirculateConverter},ConverterParameter=Monthly}">
                                    <TextBlock Text="在每个月的第: "  VerticalAlignment="Center"/>
                                    <ext:IntegerUpDown Margin="5,0,0,0" Minimum="1" Maximum="31" Value="{Binding Model.CirculateInfo.MonthDay}" LostFocus="IntegerUpDown_LostFocus" />
                                    <TextBlock Text="天的: " VerticalAlignment="Center" Margin="5,0,0,0"/>
                                    <ext:TimePicker MinWidth="100" Margin="5,0,0,0" Value="{Binding Model.CirculateInfo.StartTime}"/>
                                    <TextBlock Text="这个时候执行 (如果超出当月最大天数则按最后一天算)" VerticalAlignment="Center" Margin="5,0,0,0"/>
                                </StackPanel >
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>
                    <TextBlock Grid.Row="3" Text="提醒设置" FontSize="15" FontWeight="Bold" Margin="0,5,0,5"/>
                    <Path Grid.Row="7" Style="{StaticResource LineStyle}" />
                    <Grid Margin="30,5,0,0" Grid.Row="8" >
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <StackPanel Grid.Row="0" Orientation="Horizontal">
                            <CheckBox Content="开始前提醒:" VerticalAlignment="Center" Margin="0,5,0,0"/>
                            <TextBox MinWidth="50" Margin="10,5,0,0"/>
                            <TextBlock Text="分钟" VerticalAlignment="Center" Margin="5,5,0,0"/>
                        </StackPanel>
                        <StackPanel Grid.Row="1" Orientation="Horizontal">
                            <CheckBox Content="到期前提醒:" VerticalAlignment="Center" Margin="0,5,0,0"/>
                            <TextBox MinWidth="50" Margin="10,5,0,0"/>
                            <TextBlock Text="分钟" VerticalAlignment="Center" Margin="5,5,0,0"/>
                        </StackPanel>
                    </Grid>
                </Grid>
            </Expander>
            <TextBlock Grid.Row="6" Text="描述" Margin="5" FontSize="18" FontWeight="Bold"/>
            <Path Grid.Row="7" Style="{StaticResource LineStyle}" />
            <ext:RichTextBox MinHeight="300" Grid.Row="8" Margin="5" >
                <ext:RichTextBoxFormatBarManager.FormatBar>
                    <ext:RichTextBoxFormatBar />
                </ext:RichTextBoxFormatBarManager.FormatBar>
            </ext:RichTextBox>
            <Path Grid.Row="9" Style="{StaticResource LineStyle}" Margin="5" />
            <StackPanel Grid.Row="10" Margin="5" Orientation="Horizontal" FlowDirection="RightToLeft">
                <Button Name="Cancel" Content="取消"  MinWidth="80" MinHeight="30" Margin="100,0,20,0"/>
                <Button Name="OK" Content="{Binding Path=OKContent}" MinWidth="100"/>
            </StackPanel>
        </Grid>
    </ScrollViewer>
</UserControl>
